<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //遍历数组

        var scoreList = [98, 90, 80, 89, 75];
        //不限数据类型，但同类型往往在一个数组中
        console.log(scoreList[0]);
        console.log(scoreList[1]);

        for (var i = 0; i < 5; i++) {
            console.log(scoreList[i]);

        }
        var sum = 0;
        var length = scoreList.length;

        for (var i = 0; i < length; i++) {
            sum += scoreList[i];
        }
        console.log(sum / length);

        var scoreList1 = [{
                name: "jack",score: 98
            },
            {
                name: "sam",score: 98
            },
            {
                name: "alex",score: 98
            },
            {
                name: "rose", score: 98
            },
            {
                name: "lisa",score: 98
            }
        ];

        var length = scoreList1.length;

        for (var i = 0; i < length; i++) {
            var score = scoreList1[i].score;
            var name = scoreList1[i].name;

            console.log(name+':'+score);

            sum += score
        }

        console.log(sum);

    </script>
</body>

</html>